//
//  MBProgressHUD+CN.m
//  孟瑞瑞
//
//  Created by 孟瑞瑞 on 2016/12/23.
//  Copyright © 2018年 CSDN. All rights reserved.
//

#import "MBProgressHUD+CN.h"

@implementation MBProgressHUD (CN)

#pragma mark 显示一些信息
+ (MBProgressHUD *)showMessage:(NSString *)message toView:(UIView *)view {
    if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
    [UIActivityIndicatorView appearanceWhenContainedInInstancesOfClasses:@[[MBProgressHUD class]]].color = [UIColor colorFromHexCode:@"ffffff"];
    // 快速显示一个提示信息
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
    hud.userInteractionEnabled = NO;
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.color = [UIColor colorFromHexCode:@"#1f2124" andAlpha:0.85];
    hud.label.text = message;

    if (DEVICE_IS_IPHONE5||DEVICE_IS_IPHONE4) {
        hud.label.font = [UIFont systemFontOfSize:15];
    }
    else
    {
        hud.label.font = [UIFont systemFontOfSize:16];
    }
    hud.label.textColor = [UIColor colorFromHexCode:@"ffffff"];
    // 隐藏时候从父控件中移除
//    hud.removeFromSuperViewOnHide = YES;
    // YES代表需要蒙版效果
//    hud.dimBackground = YES;
    return hud;
}

+ (MBProgressHUD *)showMessage:(NSString *)message
{
    return [self showMessage:message toView:nil];
}

+ (void)hideHUDForView:(UIView *)view
{
    if (view == nil) view = [[UIApplication sharedApplication].windows lastObject];
    [self hideHUDForView:view animated:YES];
}

+ (void)hideHUD
{
    [self hideHUDForView:nil];
}

@end
